﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using Slja.BLL;
using Slja.Model;
using FrameWork.Interface;
using FrameWork.Components;

namespace FrameWork.web.Web.UC
{
    public partial class OrderLog : System.Web.UI.UserControl,IControlDisplayUsage
    {
        /// <summary>
        /// 订单ID
        /// </summary>
        public int OrderID
        {
            get { return (int)ViewState["_OrderID"]; }
            set { ViewState["_OrderID"] = value; }
        }       
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                BindData();
            }
        }
        private void BindData()
        {
            OrderLogBLL logbll = new OrderLogBLL();
            List<OrderLogModel> loglist;
            if (ControlUsage == DisplayUsage.DefaultDisplay)
            {
                int pageSize = Pager1.PageSize;
                int curPage = Pager1.CurrentPageIndex;
                int recordCount;                
                loglist = logbll.GetModelList(OrderID, pageSize, curPage, out recordCount);
                this.Pager1.RecordCount = recordCount;               
            }
            else
            {
                loglist = logbll.GetModelList(OrderID);
                Pager1.Visible = false;
            }
            Repeater1.DataSource = loglist;
            Repeater1.DataBind();
            
        }
        protected void Pager1_PageChanged(object sender, EventArgs e)
        {
            BindData();
        }
        /// <summary>
        /// 控件用途：显示(默认)/打印
        /// </summary>
        public Components.DisplayUsage ControlUsage
        {
            get
            {
                if (ViewState["_ControlUsage"] == null)
                {
                    ViewState["_ControlUsage"] = DisplayUsage.DefaultDisplay;
                }
                return (DisplayUsage)ViewState["_ControlUsage"];
            }
            set { ViewState["_ControlUsage"] = value; }
            
        }
    }
}